home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / MATH / NRPAS13 / GAMDEV.DEM < prev    next >
Text File  |  1991-04-29  |  1KB  |  57 lines

  1. PROGRAM d7r7 (input,output);
  2. (* driver for routine GAMDEV *)
  3. LABEL 10,99;
  4. CONST
  5.    n=20;
  6.    npts=1000;
  7.    iscal=200;
  8.    llen=50;
  9. VAR
  10.    i,ia,idum,j,k,klim : integer;
  11.    words : ARRAY [1..50] OF char;
  12.    dist : ARRAY [0..20] OF real;
  13.    glinext,glinextp : integer;
  14.    glma : ARRAY [1..55] OF real;
  15.  
  16. (*$I MODFILE.PAS *)
  17. (*$I RAN3.PAS *)
  18.  
  19. (*$I GAMDEV.PAS *)
  20.  
  21. BEGIN
  22.    idum := -13;
  23. 10:   FOR j := 0 to 20 DO BEGIN
  24.       dist[j] := 0.0
  25.    END;
  26.    writeln('Select order of Gamma distribution (n=1..20), -1 to end --  ');
  27.    readln (ia);
  28.    IF (ia < 0) THEN GOTO 99;
  29.    IF (ia > 20) THEN GOTO 10;
  30.    FOR i := 1 to npts DO BEGIN
  31.       j := trunc(gamdev(ia,idum));
  32.       IF ((j >= 0) AND (j <= 20)) THEN dist[j] := dist[j]+1
  33.    END;
  34.    writeln;
  35.    writeln ('gamma-distribution deviate, order ',
  36.          ia:2,' of ',npts:6,' points');
  37.    writeln ('x':6,'p(x)':7,'graph:':9);
  38.    FOR j := 0 to 19 DO BEGIN
  39.       dist[j] := dist[j]/npts;
  40.       FOR k := 1 to 50 DO BEGIN
  41.          words[k] := ' '
  42.       END;
  43.       klim := trunc(iscal*dist[j]);
  44.       IF (klim > llen) THEN klim := llen;
  45.       FOR k := 1 to klim DO BEGIN
  46.          words[k] := '*'
  47.       END;
  48.       write (j:6,dist[j]:8:4,'  ');
  49.       FOR k := 1 to klim DO BEGIN
  50.          write (words[k])
  51.       END;
  52.       writeln
  53.    END;
  54.    GOTO 10;
  55. 99:
  56. END.
  57.